package com.example.service.Impl;

import com.example.mapper.UserMapper;
import com.example.pojo.User;
import com.example.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Slf4j
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    //添加
    @Override
    public void add(User user) {
        userMapper.insertUser(user);
    }

    //删除
    @Override
    public void delete(Integer id) {
        userMapper.deleteById(id);
    }

    //根据id查询
    @Override
    public User query(Integer id) {
        User user = userMapper.queryById(id);
        return user;
    }

    //查询列表
    @Override
    public List<User> list() {
        List<User> userList = userMapper.list();
        return userList;
    }
    //修改
    @Override
    public void update(User user) {
        userMapper.updateByUser(user);
    }
    //根据姓名查询
    @Override
    public User query(String loginName) {
        User user = userMapper.queryByName(loginName);
        return user;
    }

    //批量导入
    @Override
    public void importUser(List<User> list1) {
        userMapper.importUser(list1);

    }
}
